package com.diamond.facade;

import java.util.List;

import org.apache.commons.beanutils.PropertyUtils;

import com.diamond.bo.MessageBO;
import com.diamond.bo.QueryMessageBO;
import com.diamond.bo.ReturnBO;
import com.diamond.entity.Message;
import com.diamond.po.MessagePO;
import com.diamond.service.IMessageService;
import com.diamond.util.DateUtils;

public class MessageFacade extends CommonFacade<Message> {
	
	public IMessageService messageService;
	
	public void setMessageService(IMessageService messageService) {
		this.messageService = messageService;
	}
	public List<?> listTop(){
		String HQL="from Message as o where o.msgType=2 and o.delStatus=0 order by o.utime desc";
		List<?> list = super.findByHQL(1, 5, HQL);
		return list;
	}
	public List<?> listKnow(){
		String HQL="from Message as o where o.msgType=1 and o.delStatus=0 order by o.utime desc";
		List<?> list = super.findByHQL(1, 1, HQL);
		return list;
	}
	
	public void addOrUpdateMessage(MessageBO messageBo) throws Exception {
		MessagePO messagePo = new MessagePO();
		PropertyUtils.copyProperties(messagePo, messageBo);
		messagePo.setUtime(DateUtils.getStringDate());
		messageService.addOrUpdateMessage(messagePo);
	}
	public ReturnBO<MessageBO> queryMessage(QueryMessageBO queryMessageBo) throws Exception {
		return messageService.queryMessage(queryMessageBo);
	}
	public Boolean checkMsgTitle(String msgTitle) throws Exception {
		return messageService.checkMsgTitle(msgTitle);
	}
	public MessageBO findMessageByMessageId(String messageId)throws Exception {
		return messageService.findMessageByMessageId(messageId);
	}
	public Boolean deleteMessage(String[] messageIds) throws Exception {
		return messageService.deleteMessage(messageIds);
	}
}
